package com.tool4j.controller;

import com.tool4j.entity.params.ToolCommonParams;
import com.tool4j.service.ChatService;
import com.tool4j.util.UserPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;

@RestController
@RequestMapping("/api/agent")
public class AgentController {

    @Autowired
    private ChatService chatService;

    @PostMapping(value = "/translation")
    public void translation(ServerWebExchange exchange, @RequestBody ToolCommonParams params) {
        Long userId = UserPermission.get(exchange).getUserId();
        chatService.translation(userId, params);
    }

    @PostMapping(value = "/conversion")
    public void conversion(@RequestBody ToolCommonParams params) {
        chatService.conversion(params);
    }

    @PostMapping(value = "/generateComment")
    public void generateComment(@RequestBody ToolCommonParams params) {
        chatService.generateComment(params);
    }

}
